#ifndef __IGAMECONTROL__
#define __IGAMECONTROL__
#include "CCGeometry.h"
#include <vector>

#pragma once
using namespace   cocos2d;
class IStrategy;
class IGrid;
struct IGameConfig
{
	unsigned int stepCount;
	unsigned int participatorNum;
	unsigned int playerNum;
	bool autoSwitchNext;
	IGameConfig();
};

struct Participator
{
	int isAI;
	int type;
};

class IGameControl
{
public:
	IGameControl();
	virtual ~IGameControl(void);
	virtual void init(IGrid* grid, IStrategy* strategy, IGameConfig config);
	inline IGrid* GetGrid(){		return m_grid;	}
	inline IStrategy* GetStrategy()	{		return m_strategy;	}
	virtual bool OnSelected(CCPoint p);
	//void ClearSelection();


	void SwitchNextPlayer();
	Participator* GetCurParticipator();

private:
	void NextPlayer();
	bool StepOver(); // return is need to switch next player

protected:
	virtual void ApplyAiPlay() = 0;
	virtual void OnSwitchNextPlayer() = 0;

protected:
	//static IGameControl* s_gameControl;
	IStrategy* m_strategy;
	IGrid* m_grid;
	IGameConfig m_gameConf;
	unsigned int m_curParticipatorIndex;
	unsigned int m_curStep;
	std::vector<Participator> m_participators;
};
#endif